package com.bianmaba.oauth2.client.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth2.client.OAuth2RestTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by xujingfeng on 2017/8/7.
 */
@RestController
public class OrderClientController {
    @Autowired
    private OAuth2RestTemplate oAuth2RestTemplate;

    @GetMapping("/order/{id}")
    public Map<String, String> getProduct(@PathVariable String id) {
        Map<String, String> data = oAuth2RestTemplate.getForObject("http://localhost:8082/resource/order/1", HashMap.class);
        return data;
    }
}
